package com.ty.common.core.valid.annotation;

import com.ty.common.core.valid.validator.NotZeroValidator;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target({FIELD, PARAMETER})
@Retention(RUNTIME)
@Constraint(validatedBy = NotZeroValidator.class)
public @interface NotZero {

    String message() default "值必须为非空且非零";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};


    /**
     * D在同一元素上定义多个 {@link NotZero} 注释。
     *
     * @see jakarta.validation.constraints.NotNull
     */
    @Target({FIELD, PARAMETER})
    @Retention(RUNTIME)
    @Documented
    @interface List {

        NotZero[] value();
    }
}
